﻿package manager
{
    import __AS3__.vec.*;
    import cmd.*;
    import com.core.*;
    import com.sh.game.consts.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.external.*;
    import flash.geom.*;
    import flash.utils.*;
    import plugin.bagN.*;
    import plugin.instance.*;
    import plugin.newteam.model.*;
    import plugin.storehouse.*;
    import plugin.taskdialog.consts.*;
    import plugin.ybstore.consts.*;
    import pluginfw.nio.*;
    import pluginfw.nio.imsg.*;
    import view.*;
    import view.message.*;
    import view.task.*;
    import view.uilt.*;
    import vo.*;

    public class PluginGroupHandler extends Object implements IGroupHandler
    {
        private var input:Input;
        private var _cfgitems:Object;
        private var isFirst:Boolean = true;
        private var _lastfix:int = 0;
        private var _timeID:uint = 0;
        private var _timeArr:Array;
        private var _delayMsgVec:Vector.<Object>;
        private var _delayUnionMsgVec:Vector.<Object>;
        private var _stipsguaji:Boolean = true;
        private var _ftimeID:uint = 0;
        private var roledatakeys:Array;
        private var inivelist:Array;
        private var cfgmaps:Array;
        public static const Error:int = 0;

        public function PluginGroupHandler()
        {
            this.input = new Input(null);
            this._cfgitems = ConfigDictionary.data.item;
            this._timeArr = [0, 5 * 60, 15 * 60, 30 * 60, 60 * 60];
            this._delayMsgVec = new Vector.<Object>;
            this._delayUnionMsgVec = new Vector.<Object>;
            this.roledatakeys = ["guide", "shouchong", "fuhuocount", "inittime", "cqxb", "curid", "qdmonth", "tglayer", "ems", "qdlq", "lastupdate", "ontime", "money", "tgid", "todayonline", "emsrefresh", "ollq", "gzupdatetime", "shouji", "qd", "fuhuotime", "onlinelj", "onlinetime", "onlinegz", "getclient", "dayinstances", "instancereset", "haswing", "loginday", "jyz", "getpay", "payreward", "daypay", "daypayreward", "emsbuy", "cfdaypay", "cfdayreward", "ssontime", "lixiantime", "jinzhuan", "dayusemoney", "scfanpai", "kflibao", "MBtime", "guanyin", "djgytishi", "getyaojiang", "supertd", "swyfloor", "armcount", "collect", "reinnum", "armhc", "guanzhilingqu", "shengwanggetnum", "lianzhitimes"];
            this.inivelist = [];
            return;
        }// end function

        public function dealSimpleMessage(param1:ISimpleMessage) : void
        {
            var i:int;
            var cfgitem:Object;
            var item:Object;
            var result:Object;
            var sbkItems:Object;
            var warItems:Object;
            var houseitem:Object;
            var maxcount:int;
            var digflag:Boolean;
            var value:Object;
            var bag:Object;
            var key:String;
            var alert:Alert2;
            var p:Point;
            var a:int;
            var itemObj:Object;
            var cfgitem1:Object;
            var item2:Object;
            var obj:Object;
            var params:Array;
            var group:int;
            var param:Object;
            var taskobj:Object;
            var goals:Object;
            var g:Object;
            var groups:Object;
            var user:Object;
            var cfg:Object;
            var roledata:Object;
            var dayinstances:Object;
            var instancereset:Object;
            var online:Object;
            var multiMsg:Object;
            var activeArr:Array;
            var activeArr2:Array;
            var uonline:Object;
            var message:* = param1;
            if (Config.Log > LogType.DEBUG)
            {
                Logger.log("接受功能服消息:" + message + "时间:" + getTimer());
            }
            if (message.getCmd() == CMDBag.Error)
            {
                ModelProxy.change("movetips", "error", message.getParam());
                if (message.getGroup() == this.getGroup("team"))
                {
                    ModelProxy.change("mainview", "addsysmsg", message.getParam());
                }
                ModelProxy.change("data", "itempoint", null);
                ModelProxy.change("data", "digflag", false);
                return;
            }
            else
            {
                if (message.getCmd() == CMDBag.Error2)
                {
                    item = message.getParam();
                    cfgitem = ConfigDictionary.data.item[item.itemid];
                    item.icon = cfgitem.icon;
                    item.name1 = cfgitem.name;
                    Alert2.show(item.name1 + "不足前往购买", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    DialogMgr.instance.open(AppDialog.SURE_BUY_STORE, item);
                }
                return;
            }// end function
            );
                    ModelProxy.change("data", "itempoint", null);
                    return;
                }
                if (message.getCmd() == CMDBag.Error3)
                {
                    Alert2.show("元宝不足前往充值", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    if (!ItemUilt.canpay)
                    {
                        ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                        return;
                    }
                    ExternalInterface.call("topay");
                }
                return;
            }// end function
            );
                    ModelProxy.change("data", "itempoint", null);
                    return;
                }
            }
            switch(message.getGroup())
            {
                case this.getGroup("bag"):
                {
                    break;
                }
                case this.getGroup("stallage"):
                {
                    break;
                }
                case this.getGroup("social"):
                {
                    break;
                }
                case 61:
                {
                    switch(message.getCmd())
                    {
                        case CMDSBK.ResGetShaBakeInfoMessage:
                        {
                            sbkItems = message.getParam();
                            ModelProxy.change("sbkinfo", "init", sbkItems);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                case this.getGroup("warehouse"):
                {
                    switch(message.getCmd())
                    {
                        case CMDStorehouse.Init:
                        {
                            warItems = message.getParam();
                            i;
                            while (i <= warItems.maxcount)
                            {
                                
                                item = warItems[i];
                                if (item)
                                {
                                    if (item[2] == 2)
                                    {
                                        item[4] = ItemObject.create(this._cfgitems[item[0]]);
                                    }
                                    else if (item[2] == 1)
                                    {
                                        item[4] = this.changeSimpleArm(item[4]);
                                    }
                                }
                                i = (i + 1);
                            }
                            ModelProxy.change("warehouse", "init", warItems);
                            break;
                        }
                        case CMDStorehouse.Swap:
                        {
                            ModelProxy.change("warehouse", "swap", message.getParam());
                            break;
                        }
                        case CMDStorehouse.Storage:
                        {
                            ModelProxy.change("warehouse", "addItem", message.getParam());
                            break;
                        }
                        case CMDStorehouse.RemoveItem:
                        {
                            ModelProxy.change("warehouse", "removeitem", message.getParam());
                            break;
                        }
                        case CMDStorehouse.TidyItem:
                        {
                            houseitem = message.getParam();
                            maxcount = houseitem.maxcount;
                            i;
                            while (i <= maxcount)
                            {
                                
                                item = houseitem[i];
                                if (item)
                                {
                                    if (item[2] == 2)
                                    {
                                        item[4] = ItemObject.create(this._cfgitems[item[0]]);
                                    }
                                    else if (item[2] == 1)
                                    {
                                        item[4] = this.changeSimpleArm(item[4]);
                                    }
                                }
                                i = (i + 1);
                            }
                            ModelProxy.change("warehouse", "tidy", houseitem);
                            break;
                        }
                        case CMDStorehouse.Expansion:
                        {
                            ModelProxy.change("warehouse", "kuorong", message.getParam());
                            break;
                        }
                        case CMDStorehouse.ChangeList:
                        {
                            ModelProxy.change("warehouse", "changelist", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("role"):
                {
                    break;
                }
                case this.getGroup("skill"):
                {
                    break;
                }
                case this.getGroup("shop"):
                {
                    switch(message.getCmd())
                    {
                        case CMDShop.Bay:
                        {
                            ModelProxy.change("mainui", "checkDrug", null);
                            result = message.getParam();
                            digflag = ModelProxy.getValue("data", "digflag");
                            if (digflag && int(result) == 140102001)
                            {
                                PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Accept, 2001);
                                ModelProxy.change("data", "digflag", false);
                            }
                            if (result == 1)
                            {
                                if (this._stipsguaji)
                                {
                                    alert = Alert2.show("您在挂机中自动购买了3组 强效太阳水 共消耗" + 1000 * 300 + "金币", "", ["设置", "知道了"], function (param1:int, param2:Object) : void
            {
                var _loc_3:* = undefined;
                var _loc_4:* = undefined;
                if (param1 == 0)
                {
                    _loc_3 = UIGlobel.pointsDic["systemset"];
                    PluginManager.instance.openPlugin("systemset", _loc_3, 3);
                }
                else if (param1 == 100)
                {
                    _stipsguaji = false;
                    _loc_4 = UIGlobel.pointsDic["systemset"];
                    PluginManager.instance.openPlugin("systemset", _loc_4, 3);
                }
                else if (param1 == 101)
                {
                    _stipsguaji = false;
                }
                return;
            }// end function
            , null, false, false);
                                    alert.x = GlobalLayer.instance.root.stageWidth - alert.width - 50;
                                    alert.y = GlobalLayer.instance.root.stageHeight - alert.height - 50;
                                }
                                else
                                {
                                    p = UIGlobel.pointsDic["systemset"];
                                    PluginManager.instance.openPlugin("systemset", p, 3);
                                }
                            }
                            break;
                        }
                        case CMDShop.GetList:
                        {
                            ModelProxy.change("shop", "getlist", message.getParam());
                            break;
                        }
                        case CMDShop.Durables:
                        {
                            value = message.getParam();
                            if (value == null)
                            {
                                break;
                            }
                            bag = UserData.getBagData();
                            key;
                            a;
                            while (a < this.roledatakeys.length)
                            {
                                
                                if (a < result.length)
                                {
                                    key = this.roledatakeys[a];
                                }
                                a = (a + 1);
                            }
                            i;
                            while (i <= bag.maxcount)
                            {
                                
                                item = bag[i];
                                if (item && item[2] == 1 && key == item[1])
                                {
                                    item[4].durable = value[key];
                                }
                                i = (i + 1);
                            }
                            ModelProxy.change("bag", "durables", message.getParam());
                            ModelProxy.change("role", "durables", message.getParam());
                            break;
                        }
                        case CMDShop.AllAsk:
                        {
                            ModelProxy.change("leftTishi", "xiuli", message.getParam());
                            break;
                        }
                        case CMDShop.MarkBuyItem2:
                        {
                            ModelProxy.change("jifenshop", "MarkBuy", message.getParam());
                            break;
                        }
                        case CMDShop.MarkBuyCount:
                        {
                            ModelProxy.change("jifenshop", "MarkBuyCount", message.getParam());
                            break;
                        }
                        case CMDShop.ScrectCount:
                        {
                            ModelProxy.change("secrestore", "init", message.getParam());
                            break;
                        }
                        case CMDShop.RefreshSecretShop:
                        {
                            ModelProxy.change("secrestore", "refresh", message.getParam());
                            break;
                        }
                        case CMDShop.SecretBuy:
                        {
                            ModelProxy.change("secrestore", "secretbuy", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("chatFlash"):
                {
                    break;
                }
                case this.getGroup("activity"):
                {
                    break;
                }
                case this.getGroup("store"):
                {
                    switch(message.getCmd())
                    {
                        case CMDStore.Init:
                        {
                            ModelProxy.change("store", "init", message.getParam());
                            break;
                        }
                        case CMDStore.ItemPrice:
                        {
                            result = message.getParam();
                            if (result[0] == 1)
                            {
                                ModelProxy.change("npcdialog", "itemprice", result[1]);
                            }
                            else if (result[0] == 2)
                            {
                                ModelProxy.change("qianghua", "itemprice", result[1]);
                            }
                            else if (result[0] == 3)
                            {
                                ModelProxy.change("activity", "itemprice", result[1]);
                            }
                            else if (result[0] == 4)
                            {
                                ModelProxy.change("fashion", "itemprice", result[1]);
                            }
                            else if (result[0] == 5)
                            {
                                ModelProxy.change("jianding", "itemprice", result[1]);
                            }
                            else if (result[0] == 6)
                            {
                                itemObj = result[1][0];
                                cfgitem = ConfigDictionary.data.item[itemObj.itemid];
                                cfgitem1 = ConfigDictionary.data.item[itemObj.itemneed];
                                itemObj.icon = cfgitem.icon;
                                itemObj.name1 = cfgitem.name;
                                itemObj.lcount = cfgitem1.bufferparam;
                                DialogMgr.instance.open(AppDialog.SURE_BUY_STORE, itemObj);
                            }
                            break;
                        }
                        case CMDStore.GetPrice:
                        {
                            item2 = message.getParam();
                            if (item2)
                            {
                                cfgitem = ConfigDictionary.data.item[item2.itemid];
                                item2.icon = cfgitem.icon;
                                item2.name1 = cfgitem.name;
                                DialogMgr.instance.open(AppDialog.SURE_BUY_STORE, item2);
                            }
                            break;
                        }
                        case CMDStore.NewOrder:
                        {
                            result = message.getParam();
                            ModelProxy.change("data", "yuanbao", result[0]);
                            ModelProxy.change("mainui", "checkYuanBao", null);
                            ModelProxy.change("leftTishi", "getyuanbao", result[0]);
                            if (result[1] == 1 && result[0] >= 800)
                            {
                                ModelProxy.change("mainui", "showmoney", null);
                            }
                            break;
                        }
                        case CMDStore.LimitStore:
                        {
                            ModelProxy.change("limitstore", "init", message.getParam());
                            break;
                        }
                        case CMDStore.LimitStoreRemain:
                        {
                            ModelProxy.change("limitstore", "buyremain", message.getParam());
                            break;
                        }
                        case CMDStore.LimitStoreNum:
                        {
                            ModelProxy.change("store", "updatanum", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("qianghua"):
                {
                    break;
                }
                case this.getGroup("rank"):
                {
                    switch(message.getCmd())
                    {
                        case CMDRank.Nbvalue:
                        {
                            ModelProxy.change("rank", "nbvalue", message.getParam());
                            break;
                        }
                        case CMDRank.ChangePage:
                        {
                            ModelProxy.change("rank", "changepage", message.getParam());
                            break;
                        }
                        case CMDRank.GetRankBack:
                        {
                            ModelProxy.change("rank", "getrankback", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("horse"):
                {
                    break;
                }
                case this.getGroup("wing"):
                {
                    break;
                }
                case this.getGroup("taskdialog"):
                {
                    switch(message.getCmd())
                    {
                        case CMDTask.Error:
                        {
                            ModelProxy.change("movetips", "error", message.getParam());
                            break;
                        }
                        case CMDTask.GetTask:
                        {
                            ModelProxy.change("task", "gettask", message.getParam());
                            break;
                        }
                        case CMDTaskdialog.Accept:
                        {
                            param = message.getParam();
                            taskobj = UserData.getData(UserDataType.Task);
                            goals = param[2];
                            var _loc_3:int = 0;
                            var _loc_4:* = goals;
                            while (_loc_4 in _loc_3)
                            {
                                
                                g = _loc_4[_loc_3];
                                taskobj["goal_" + g] = goals[g];
                            }
                            groups = param[3];
                            var _loc_3:int = 0;
                            var _loc_4:* = groups;
                            while (_loc_4 in _loc_3)
                            {
                                
                                g = _loc_4[_loc_3];
                                taskobj[g] = groups[g];
                            }
                            ModelProxy.change("taskdialog", "accept", message.getParam());
                            ModelProxy.change("tasktrack", "init", taskobj);
                            ModelProxy.change("dazibao", "check", [4, param[0]]);
                            if (param[1] == 2)
                            {
                                ModelProxy.change("tasktrack", "togoal", param[0]);
                            }
                            else if (param[1] == 3)
                            {
                                ModelProxy.change("tasktrack", "dosome", param[0]);
                            }
                            break;
                        }
                        case CMDTaskdialog.Submit:
                        {
                            result = message.getParam();
                            ModelProxy.change("taskdialog", "submit", result);
                            ModelProxy.change("dazibao", "check", [5, result[0]]);
                            break;
                        }
                        case CMDTaskdialog.FlushLevel:
                        {
                            ModelProxy.change("taskdialog", "flushlevel", message.getParam());
                            break;
                        }
                        case CMDTaskdialog.BuyCount:
                        {
                            obj = UserData.getData(UserDataType.Task);
                            params = message.getParam();
                            group = params[0];
                            obj["buy_" + group] = params[1];
                            obj["group_" + group] = params[2];
                            ModelProxy.change("tasktrack", "init", obj);
                            ModelProxy.change("taskdialog", "buycount", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("fcm"):
                {
                    switch(message.getCmd())
                    {
                        default:
                        {
                            break;
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("business"):
                {
                    break;
                }
                case this.getGroup("instance"):
                {
                    switch(message.getCmd())
                    {
                        case CMDInstance.GetInstance:
                        {
                            ModelProxy.change("mainuiInstance", "init", message.getParam());
                            ModelProxy.change("mainui", "updatetdtime", message.getParam());
                            break;
                        }
                        case CMDInstance.Rewards:
                        {
                            user = UserData.getUserData();
                            cfg = ConfigDictionary.data.maplist;
                            ModelProxy.change("mainuiInstance", "lasttime", null);
                            result = message.getParam();
                            DialogMgr.instance.open(AppDialog.FB_DROPS, [result[1], cfg[result[0]].name, result[0]]);
                            ModelProxy.change("dazibao", "check", [3, result[0]]);
                            GuideView.getInstance().doGuide(GuideType.GUIDE_FB);
                            break;
                        }
                        case CMDInstance.ResetShow:
                        {
                            Alert2.show("本次重置需要消耗" + message.getParam() + "元宝", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("instance", CMDInstance.ResetTianguan, null);
                }
                return;
            }// end function
            );
                            break;
                        }
                        case CMDInstance.HuoDongApp:
                        {
                            ModelProxy.change("plugin", "close", "npcdialog");
                            break;
                        }
                        case CMDInstance.GetDayInstances:
                        {
                            result = message.getParam();
                            ModelProxy.change("data", "dayinstances", result[0]);
                            ModelProxy.change("mainui", "dayInstanceChange", null);
                            ModelProxy.change("data", "instancereset", result[1]);
                            ModelProxy.change("tasktrack", "getonline", result);
                            break;
                        }
                        case CMDInstance.DayInfo:
                        {
                            result = message.getParam();
                            roledata = UserData.getOnlineData();
                            if (roledata.dayinstances == null)
                            {
                                roledata.dayinstances = new Object();
                            }
                            dayinstances = roledata.dayinstances;
                            dayinstances[result[0]] = result[1];
                            ModelProxy.change("mainui", "dayInstanceChange", null);
                            instancereset = ModelProxy.getValue("data", "instancereset");
                            if (instancereset == null)
                            {
                                instancereset = new Object();
                                ModelProxy.change("data", "instancereset", instancereset);
                            }
                            instancereset[result[0]] = result[2];
                            ModelProxy.change("tasktrack", "getonline", result);
                            ModelProxy.change("data", "dayinstances", dayinstances);
                            this.checkInstanceCount();
                            break;
                        }
                        case CMDInstance.InstanceResult:
                        {
                            result = message.getParam();
                            ModelProxy.change("plugin", "change", {target:"fbresult", point:new Point(600, 370), data:result});
                            break;
                        }
                        case CMDInstance.GetRewards:
                        {
                            ModelProxy.change("plugin", "close", "fbresult");
                            break;
                        }
                        case CMDInstance.ShitRankReward:
                        {
                            ModelProxy.change("taskinstance", "getRew", null);
                            break;
                        }
                        case CMDInstance.ShitCom:
                        {
                            online = UserData.getOnlineData();
                            online.shitinstance = message.getParam();
                            break;
                        }
                        case CMDInstance.FlipReward:
                        {
                            ModelProxy.change("fbcard", "flipRew", message.getParam());
                            break;
                        }
                        case CMDInstance.GetFlip:
                        {
                            result = message.getParam();
                            ModelProxy.change("plugin", "change", {target:"fbcardresult", data:result});
                            break;
                        }
                        case CMDInstance.SJGet:
                        {
                            result = message.getParam();
                            result = result.source;
                            DialogMgr.instance.open(AppDialog.DBQB_RANK, result);
                            break;
                        }
                        case CMDInstance.SJReward:
                        {
                            result = message.getParam();
                            DialogMgr.instance.open(AppDialog.DBQB_RESULT, result);
                            break;
                        }
                        case CMDMultiInstance.MultiCreate:
                        {
                            ModelProxy.change("multiinstance", "multiopen", message.getParam());
                            break;
                        }
                        case CMDMultiInstance.Multileave:
                        {
                            ModelProxy.change("multiinstance", "multileave", message.getParam());
                            break;
                        }
                        case CMDMultiInstance.MultiJoin:
                        {
                            if (ModelProxy.getValue("data", "isMultiInstanceInit"))
                            {
                                ModelProxy.change("multiinstance", "multijoin", message.getParam());
                                if (ModelProxy.getValue("data", "isMultiInstanceJoinning"))
                                {
                                    ModelProxy.change("plugin", "open", {target:"multiinstance"});
                                    ModelProxy.change("data", "isMultiInstanceJoinning", false);
                                }
                            }
                            else
                            {
                                ModelProxy.change("data", "multiInstanceDelay", message.getParam());
                                ModelProxy.change("plugin", "open", {target:"multiinstance"});
                            }
                            break;
                        }
                        case CMDMultiInstance.MultiFriends:
                        {
                            multiMsg = message.getParam();
                            Alert2.show("您的好友" + multiMsg[2] + "开启团队副本" + ConfigDictionary.data.maplist[multiMsg[1]].name + "，并邀请您加入队伍，是否接受？", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("multiinstance", CMDMultiInstance.MultiJoin, [UserData.getUserData("rid"), multiMsg[0]]);
                }
                return;
            }// end function
            );
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("online"):
                {
                    break;
                }
                case this.getGroup("ems"):
                {
                    break;
                }
                case this.getGroup("zbhsy"):
                {
                    break;
                }
                case this.getGroup("achievement"):
                {
                    break;
                }
                case this.getGroup("xunbao"):
                {
                    break;
                }
                case 121:
                {
                    switch(message.getCmd())
                    {
                        case 1:
                        {
                            ModelProxy.change("zone", "findStagePath", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("juezhan"):
                {
                    break;
                }
                case this.getGroup("active"):
                {
                    switch(message.getCmd())
                    {
                        case CMDActive.GetAct:
                        {
                            ModelProxy.change("active", "getAct", message.getParam());
                            break;
                        }
                        case CMDActive.CompleteAct:
                        {
                            result = message.getParam();
                            ModelProxy.change("active", "completeAct", result);
                            activeArr = ModelProxy.getValue("data", "activebonus");
                            activeArr[4] = result.bonus;
                            i;
                            while (i < 4)
                            {
                                
                                if (activeArr[i] == 2)
                                {
                                    ModelProxy.change("mainui", "playhuoyue", null);
                                    break;
                                }
                                else if (activeArr[i] == 0)
                                {
                                    switch(i)
                                    {
                                        case 0:
                                        {
                                            if (activeArr[4] >= 20)
                                            {
                                                ModelProxy.change("mainui", "playhuoyue", null);
                                                return;
                                            }
                                            break;
                                        }
                                        case 1:
                                        {
                                            if (activeArr[4] >= 50)
                                            {
                                                ModelProxy.change("mainui", "playhuoyue", null);
                                                return;
                                            }
                                            break;
                                        }
                                        case 2:
                                        {
                                            if (activeArr[4] >= 80)
                                            {
                                                ModelProxy.change("mainui", "playhuoyue", null);
                                                return;
                                            }
                                            break;
                                        }
                                        case 3:
                                        {
                                            if (activeArr[4] >= 100)
                                            {
                                                ModelProxy.change("mainui", "playhuoyue", null);
                                                return;
                                            }
                                            break;
                                        }
                                        default:
                                        {
                                            break;
                                        }
                                    }
                                }
                                i = (i + 1);
                            }
                            break;
                        }
                        case CMDActive.GetReward:
                        {
                            ModelProxy.change("active", "getReward", message.getParam());
                            activeArr2 = ModelProxy.getValue("data", "activebonus");
                            activeArr2[(message.getParam()[0] - 1)] = 1;
                            break;
                        }
                        case CMDActive.GetOnlineTime:
                        {
                            ModelProxy.change("mainui", "activeTime", message.getParam());
                            break;
                        }
                        case CMDActive.checkOnline:
                        {
                            ModelProxy.change("mainui", "stopActiveTime", null);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case this.getGroup("monopoly"):
                {
                    switch(message.getCmd())
                    {
                        case CMDMonopoly.CheckOne:
                        {
                            ModelProxy.change("monopoly", "login", message.getParam());
                            break;
                        }
                        case CMDMonopoly.CheckBonus:
                        {
                            uonline = UserData.getOnlineData();
                            uonline["amtb"] = message.getParam();
                            ModelProxy.change("monopoly", "getReward", null);
                            break;
                        }
                        case CMDMonopoly.DfwSecond:
                        {
                            ModelProxy.change("monopoly", "run", message.getParam());
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function updatefashiontime(param1:int, param2:int = 0) : void
        {
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_3:* = UserData.getOnlineData("fashiontimeup");
            if (this._ftimeID > 0)
            {
                clearTimeout(this._ftimeID);
                this._ftimeID = 0;
            }
            if (param1 > 0)
            {
                _loc_5 = (ModelProxy.getValue("data", "servertime") + Number(getTimer())) / 1000;
                if (param2 == 1)
                {
                    _loc_4 = param1 - _loc_5;
                    if (_loc_4 == 0)
                    {
                        this.fashionupdate();
                    }
                    else if (_loc_4 == 3600)
                    {
                        this.fashionupdate();
                    }
                    else if (_loc_4 < 100000)
                    {
                        if (_loc_4 > 3600)
                        {
                            this._ftimeID = setTimeout(this.fashionupdate, (_loc_4 - 3600) * 1000);
                        }
                        else if (_loc_4 > 0)
                        {
                            this._ftimeID = setTimeout(this.fashionupdate, _loc_4 * 1000);
                        }
                    }
                }
                else
                {
                    _loc_4 = param1 - _loc_5 - 3600;
                    if (_loc_4 > 0)
                    {
                        if (_loc_4 < 100000)
                        {
                            this._ftimeID = setTimeout(this.fashionupdate, _loc_4 * 1000);
                        }
                    }
                    else
                    {
                        this.fashionupdate();
                    }
                }
            }
            return;
        }// end function

        private function fashionupdate() : void
        {
            if (this._ftimeID > 0)
            {
                clearTimeout(this._ftimeID);
                this._ftimeID = 0;
            }
            return;
        }// end function

        private function checkInstanceCount() : int
        {
            var _loc_6:* = undefined;
            var _loc_7:Array = null;
            var _loc_8:Object = null;
            var _loc_9:Object = null;
            var _loc_10:Array = null;
            var _loc_1:* = ConfigDictionary.data.instanceGate;
            var _loc_2:* = ModelProxy.getValue("data", "dayinstances");
            var _loc_3:* = UserData.getUserData();
            var _loc_4:* = ConfigDictionary.data.instance;
            var _loc_5:int = 0;
            for (_loc_6 in _loc_1)
            {
                
                _loc_7 = _loc_1[_loc_6];
                for each (_loc_8 in _loc_7)
                {
                    
                    _loc_9 = _loc_4[_loc_8.mapid];
                    if (_loc_9 == null)
                    {
                        continue;
                    }
                    _loc_10 = String(_loc_9.limit_times).split(" ");
                    if (_loc_9.open_level <= _loc_3.level)
                    {
                        if (_loc_2 == null || !_loc_2.hasOwnProperty(_loc_8.mapid))
                        {
                            _loc_5 = _loc_5 + int(_loc_10[1]);
                            continue;
                        }
                        if (int(_loc_2[_loc_8.mapid]) < int(_loc_10[1]))
                        {
                            _loc_5 = _loc_5 + (int(_loc_10[1]) - int(_loc_2[_loc_8.mapid]));
                        }
                    }
                }
            }
            return _loc_5;
        }// end function

        private function backfunc(param1:int, param2:Object) : void
        {
            if (param1 == 0)
            {
                PluginManager.instance.sendToServer("union", CMDUnion.UnionFriend, param2.unionid);
            }
            return;
        }// end function

        private function invite(param1) : void
        {
            var param0:* = param1;
            if (param0 == null)
            {
                return;
            }
            var i:int;
            while (i < this.inivelist.length)
            {
                
                if (this.inivelist[i] == param0)
                {
                    return;
                }
                i = (i + 1);
            }
            this.inivelist.push(param0);
            Alert2.show("<font color =\'#00ff00\'>" + param0.name + "</fonr><font color =\'#ffffff\'>邀请你加入行会</font><font color =\'#00ff00\'>" + param0.unionname + "</fonr>", "", ["同意", "拒绝"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("union", CMDUnion.AgreeInvite, param2);
                }
                return;
            }// end function
            , param0.unionid);
            return;
        }// end function

        private function leave(param1:String) : void
        {
            ModelProxy.change("movetips", "error", param1);
            ModelProxy.change("data", "user.unionid", 0);
            ModelProxy.change("data", "user.unionname", null);
            ModelProxy.change("data", "unioninfo", null);
            ModelProxy.change("plugin", "close", "union");
            ModelProxy.change("mainui", "removeChatTips", 1);
            return;
        }// end function

        private function ChangeUnion(param1:Object) : void
        {
            var _loc_3:String = null;
            var _loc_2:* = ModelProxy.getValue("union", "unioninfo");
            if (_loc_2)
            {
                for (_loc_3 in param1)
                {
                    
                    _loc_2[_loc_3] = param1[_loc_3];
                }
            }
            ModelProxy.change("union", "unioninfo", _loc_2);
            return;
        }// end function

        private function unionSetPos(param1:Object) : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:String = null;
            var _loc_6:Object = null;
            var _loc_7:Array = null;
            var _loc_8:String = null;
            var _loc_9:int = 0;
            var _loc_2:* = ModelProxy.getValue("union", "unioninfo");
            if (_loc_2)
            {
                _loc_3 = param1.pos;
                _loc_4 = param1.rid;
                _loc_5 = param1.posname;
                _loc_6 = _loc_2.members;
                _loc_7 = _loc_6.source;
                _loc_8 = _loc_2.creatorname;
                _loc_9 = 0;
                while (_loc_9 < _loc_7.length)
                {
                    
                    if (_loc_7[_loc_9].rid == _loc_4)
                    {
                        _loc_7[_loc_9].pos = _loc_3;
                        _loc_7[_loc_9].posname = _loc_5;
                        _loc_8 = _loc_7[_loc_9].name;
                        break;
                    }
                    _loc_9++;
                }
                if (_loc_3 == 0)
                {
                    _loc_9 = 0;
                    while (_loc_9 < _loc_7.length)
                    {
                        
                        if (_loc_7[_loc_9].rid == _loc_2.creatorid)
                        {
                            _loc_7[_loc_9].pos = 99;
                            _loc_7[_loc_9].posname = "会员";
                            break;
                        }
                        _loc_9++;
                    }
                    _loc_2.creatorid = _loc_4;
                    _loc_2.creatorname = _loc_8;
                }
                ModelProxy.change("movetips", "error", param1.whoname + "被设为" + _loc_5);
                ModelProxy.change("union", "unioninfo", _loc_2);
            }
            return;
        }// end function

        private function ZhanTarget(param1) : void
        {
            var _loc_2:* = "你的战友" + param1.name + "召唤你";
            Alert2.show(_loc_2, "", ["接受", "", "拒绝"], this.callback, param1);
            return;
        }// end function

        public function callback(param1:Object, param2:Object) : void
        {
            if (param1 == 0)
            {
                PluginManager.instance.sendToServer("team", CMDteam.AgreeZhan, param2.rid);
            }
            return;
        }// end function

        private function showSocialtips(param1) : void
        {
            var _loc_3:String = null;
            if (this.cfgmaps == null)
            {
                this.cfgmaps = ConfigDictionary.data.maplist;
            }
            var _loc_2:* = param1;
            if (_loc_2.online)
            {
                if (this.cfgmaps[_loc_2.stageid] == null)
                {
                    _loc_3 = "情谊值" + _loc_2.qinmi + "\n" + _loc_2.xinqin;
                    ModelProxy.change("tips", "normal", {data:_loc_3, p:new Point(GlobalLayer.instance.root.mouseX, GlobalLayer.instance.root.mouseY)});
                }
                else
                {
                    _loc_3 = this.cfgmaps[_loc_2.stageid].name + " " + _loc_2.x + "," + _loc_2.y + "  情谊值" + _loc_2.qinmi + "\n" + _loc_2.xinqin;
                    ModelProxy.change("tips", "normal", {data:_loc_3, p:new Point(GlobalLayer.instance.root.mouseX, GlobalLayer.instance.root.mouseY)});
                }
            }
            return;
        }// end function

        private function changeSimpleArm(param1:Object) : Object
        {
            if (param1 == null)
            {
                return null;
            }
            var _loc_2:* = ItemObject.create(this._cfgitems[param1[1]]);
            _loc_2.id = int(param1[0]);
            _loc_2.superlevel = int(param1[2]);
            _loc_2.totalupvalue = int(param1[3]);
            _loc_2.upvalue = int(param1[4]);
            _loc_2.xq = param1[5];
            _loc_2.zs = int(param1[6]);
            _loc_2.luck = int(param1[7]);
            _loc_2.bind = int(param1[8]);
            _loc_2.appraisal = param1[9];
            _loc_2.timeout = param1[10];
            return _loc_2;
        }// end function

        private function showFlashUpdate() : void
        {
            var _loc_1:* = ModelProxy.getValue("data", "noupdate");
            if (_loc_1)
            {
                return;
            }
            var _loc_2:* = GlobalLayer.instance.root.stageWidth;
            var _loc_3:* = GlobalLayer.instance.root.stageHeight;
            ModelProxy.change("plugin", "open", {target:"flashupdate", point:new Point(_loc_2 - 400, _loc_3 - 294)});
            return;
        }// end function

        private function getGroup(param1:String) : int
        {
            var _loc_2:* = PluginManager.instance.getGroupId(param1);
            return _loc_2;
        }// end function

        public function dealBufferMessage(param1:IBufferMessage) : void
        {
            var _loc_4:Object = null;
            var _loc_5:int = 0;
            var _loc_2:* = new Object();
            if (this.input == null)
            {
                this.input = new Input(null);
            }
            var _loc_3:* = param1.getBody();
            _loc_3.position = 0;
            this.input.setBytes(_loc_3);
            switch(param1.getGroup())
            {
                case 61:
                {
                    switch(param1.getCmd())
                    {
                        case CMDSBK.SBKMsg:
                        {
                            _loc_2.unionName = this.input.readString();
                            _loc_2.unionid = this.input.readVarInt(false);
                            _loc_2.totalExp = this.input.readVarInt(false);
                            _loc_2.area = this.input.readVarInt(false);
                            _loc_2.endTime = this.input.readVarInt(false);
                            ModelProxy.change("mainui", "showsbk", _loc_2);
                            ModelProxy.change("data", "insbk", true);
                            break;
                        }
                        case CMDSBK.SBKOver:
                        {
                            _loc_2.reason = this.input.readVarInt(false);
                            ModelProxy.change("mainui", "closesbk", null);
                            if (_loc_2.reason > 0)
                            {
                                if (_loc_2.reason == UserData.getUserData("unionid"))
                                {
                                    DialogMgr.instance.open(AppDialog.EMS_FAIL, {type:2});
                                }
                                else
                                {
                                    DialogMgr.instance.open(AppDialog.EMS_FAIL, {type:3});
                                }
                            }
                            ModelProxy.change("data", "insbk", false);
                            break;
                        }
                        case CMDSBK.ResFlag:
                        {
                            this.input.setBytes(_loc_3);
                            _loc_2.npcid = this.input.readVarInt(false);
                            ModelProxy.change("zone", "sbkflag", _loc_2.npcid);
                            break;
                        }
                        case CMDSBK.SBKFLAG:
                        {
                            this.input.setBytes(_loc_3);
                            _loc_2.npcid = this.input.readVarInt(false);
                            ModelProxy.change("zone", "sbkflag", _loc_2.npcid);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case 109:
                {
                    switch(param1.getCmd())
                    {
                        case CMDTaskdialog.DeleteTask:
                        {
                            _loc_4 = UserData.getData(UserDataType.Task);
                            _loc_5 = this.input.readVarInt(false);
                            if (_loc_4["tid_" + _loc_5])
                            {
                                _loc_4["tid_" + _loc_5] = null;
                            }
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                case 90:
                {
                    switch(param1.getCmd())
                    {
                        case CMDInstance.MultRewards:
                        {
                            ModelProxy.change("mainuiInstance", "isGet", null);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function dealProxyMessage(param1:IProxyMessage) : void
        {
            return;
        }// end function

    }
}
